package chapter03.reg

import chisel3._

object ShiftRegister {
  def apply[T <: Data](in: T, n: Int, en: Bool = true.B): T = {
    // The order of tests reflects the expected use cases.
    if (n != 0) {
      RegEnable(apply(in, n - 1, en), en)
    } else {
      in
    }
  }

  def apply[T <: Data](in: T, n: Int, resetData: T, en: Bool): T = {
    // The order of tests reflects the expected use cases.
    if (n != 0) {
      RegEnable(apply(in, n - 1, resetData, en), resetData, en)
    } else {
      in
    }
  }
}